// 提供首页的模拟接口
import Mock from 'mockjs'
import qs from 'qs'
export default {
  brand: config => {
    // 1. 先取出键值对字符串（查询字符串）
    // 2. 使用qs（nodejs的模块）解析字符串
    const queryStr = config.url.split('?')[1]
    const queryObj = qs.parse(queryStr) || {}

    const limit = queryObj.limit || 10
    const brands = []
    for (let i = 0; i < limit; i++) {
      brands.push(Mock.mock({
        id: '@id',

        picture: `http://zhoushugang.gitee.io/erabbit-client-pc-static/uploads/brand_goods_${i % 5 + 1}.jpg`,
        name: '@ctitle(6,8)',
        desc: '@ctitle(20,30)',
        place: '@city'
      }))
    }
    return {
      msg: '获取品牌成功',
      result: brands
    }
  }
}
